<template>
  <div class="top" style="display: flex;align-items: center;">
    <p class="left" style="width: 8px;height: 25px;background-color: #f6d39c;margin-right: 10px;border-radius: 3px;"></p>
    <el-icon style="color: white;margin-right: 10px;font-size: 22px;">
      <HomeFilled />
    </el-icon>
    <p style="color: white;font-size: 22px;font-weight: 600;">{{ $t('个人主页') }}</p>
  </div>

  <!--   <div class="box1" style="width: 100%;height: 150px; margin-top: 25px;display: flex;"> -->
  <el-row :gutter="40" class="panel-group" style="margin-top: 20px;">
    <el-col :xs="12" :sm="12" :lg="5" class="card-panel-col">
      <div class="smallbox"
        style="height: 150px;background-color: #fd7d89;border-radius: 20px;padding: 15px;box-sizing: border-box;">
        <p class="p1 press" style="color: white;font-size: 32px;">{{ userInfo.price }}</p>
        <p style="color: white;margin-top: 10px;">{{ $t('账户余额') }}</p>
        <el-progress :percentage="50" :show-text="false" :text-inside="true" :stroke-width="13"
          style="margin-top: 20px;" />
      </div>
    </el-col>
    <!--  <el-col :xs="12" :sm="12" :lg="4" class="card-panel-col">
      <div class="smallbox"
        style="height: 150px;background-color:#36d4f4 ;border-radius: 20px;padding: 15px;box-sizing: border-box;">
        <p class="p1" style="color: white;font-size: 32px;">0</p>
        <p style="color: white;margin-top: 10px;">账户数</p>
        <el-progress :percentage="50" :show-text="false" :text-inside="true" :stroke-width="13"
          style="margin-top: 20px;" />
      </div>
    </el-col> -->
    <el-col :xs="12" :sm="12" :lg="5" class="card-panel-col">
      <div class="smallbox"
        style="height: 150px;background-color:#56dc99 ;border-radius: 20px;padding: 15px;box-sizing: border-box;">
        <p class="p1 press" style="color: white;font-size: 32px;">{{ userInfo.recharge_money }}</p>
        <p style="color: white;margin-top: 10px;">{{ $t('入金总量') }}</p>
        <el-progress :percentage="50" :show-text="false" :text-inside="true" :stroke-width="13"
          style="margin-top: 20px;" />
      </div>
    </el-col>
    <!-- <el-col :xs="12" :sm="12" :lg="4" class="card-panel-col">
      <div class="smallbox"
        style="height: 150px;background-color: #c866e4;border-radius: 20px;padding: 15px;box-sizing: border-box;">
        <p class="p1" style="color: white;font-size: 32px;">0/0</p>
        <p style="color: white;margin-top: 10px;">总佣金/未提取</p>
        <el-progress :percentage="50" :show-text="false" :text-inside="true" :stroke-width="13"
          style="margin-top: 20px;" />
      </div>
    </el-col> -->
    <el-col :xs="12" :sm="12" :lg="5" class="card-panel-col">
      <div class="smallbox"
        style="height: 150px;background-color: #fade53;border-radius: 20px;padding: 15px;box-sizing: border-box;">
        <p class="p1 press" style="color: white;font-size: 32px;">{{ userInfo.order_cnt }}</p>
        <p style="color: white;margin-top: 10px;">{{ $t('持单数') }}</p>
        <el-progress :percentage="50" :show-text="false" :text-inside="true" :stroke-width="13"
          style="margin-top: 20px;" />
      </div>
    </el-col>
    <el-col :xs="12" :sm="12" :lg="5" class="card-panel-col">
      <div class="smallbox"
        style="height: 150px; background-color: #48a1e8; border-radius: 20px; padding: 15px; box-sizing: border-box;">
        <p class="p1 press" style="color: white; font-size: 32px;">{{ userInfo.order_num }}</p>
        <p style="color: white; margin-top: 10px;">{{ $t('交易手数') }}</p>
        <el-progress :percentage="50" :show-text="false" :text-inside="true" :stroke-width="13"
          style="margin-top: 20px;" />
      </div>
    </el-col>
  </el-row>

  <el-row :gutter="40" class="panel-group" style="margin-top: 20px;">
    <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
      <a :href="backendUrl" target="_blank">
        <div class="nav"
          style="height: 100px; background-color: #313644;border-radius: 15px;display: flex;align-items:center;justify-content: space-between;padding-left: 30px;padding-right: 30px;">
          <p style="color: #56dc99; font-size: 20px; font-weight: 600;">{{ $t('在线客服') }}</p>
          <el-icon class="press" style="color:#56dc99 ;font-size: 50px;">
            <Promotion />
          </el-icon>
        </div>
      </a>
    </el-col>
    <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
      <div class="nav"
        style="height: 100px; background-color: #313644;border-radius: 15px;display: flex;align-items:center;justify-content: space-between;padding-left: 30px;padding-right: 30px;">
        <p style="color: #fd7d89;font-size: 20px;font-weight: 600;">{{ $t('出金') }}</p>
        <el-icon class="press" style="color:#fd7d89 ;font-size: 50px;" @click="Applywithdrawl">
          <Pointer />
        </el-icon>
      </div>
    </el-col>
    <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
      <div class="nav"
        style="height: 100px; background-color: #313644;border-radius: 15px;display: flex;align-items:center;justify-content: space-between;padding-left: 30px;padding-right: 30px;">
        <p style="color: #48a1e8;font-size: 20px;font-weight: 600;">{{ $t('入金') }}</p>
        <el-icon class="press" style="color:#48a1e8 ;font-size: 50px;" @click="navigateToAccountIn">
          <Promotion />
        </el-icon>
      </div>
    </el-col>
    <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">

    </el-col>
  </el-row>

  <!-- <div class="box3" style="margin-top: 20px;">
    <el-row :gutter="0" class="custom-row">
      <el-col :xs="24" :sm="24" :lg="12" style="  background-color: #313644;border-radius: 20px;">
        <div class="chart-wrapper" style="height:300px ;border-radius: 20px;">
          <div class="topbox">
            <div class="small"
              style="width: 100%; height: 50px;display: flex;align-items: center;padding-left: 15px;border-bottom: 2px solid black;">
              交易量</div>
          </div>
          <LineChart />
        </div>
      </el-col>

      <el-col :xs="24" :sm="24" :lg="12" style="  background-color: #313644;border-radius: 20px;margin-right: -20px;">
        <div class="chart-wrapper" style="height:300px ;border-radius: 20px;">
          <div class="topbox">
            <div class="small"
              style="width: 100%; height: 50px;display: flex;align-items: center;padding-left: 15px;border-bottom: 2px solid black;">
              每日盈亏</div>
          </div>
          <DayChart />
        </div>
      </el-col>
    </el-row>

  </div> -->

  <div class="box3" style="margin-top: 20px;margin-bottom: 100px;">
    <el-row :gutter="0" class="custom-row">
      <el-col :xs="24" :sm="24" :lg="12" style="  background-color: #313644;border-radius: 20px;">
        <div class="chart-wrapper" style="height:300px ;border-radius: 20px;overflow-y: auto;">
          <div class="topbox" style="margin-top: 20px;padding-left: 15px; box-sizing: border-box;margin-bottom: 10px;">
            {{ $t('消息公告') }}
          </div>
          <el-table :data="noticeList" style="width: 100%" @click="toMessage">
            <el-table-column prop="time_str" :label="$t('发布时间')" width="180" />
            <el-table-column prop="name" :label="$t('公告标题')" />
          </el-table>
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import { HomeFilled, Promotion, Pointer } from "@element-plus/icons-vue";
import LineChart from './compontent/LineChart.vue'
import DayChart from './compontent/DayChart.vue'
import Applywithdrawl from "../WithDrawal/applywithdrawl.vue";
import { noticeListApi, noticedetailApi, UserInfoApi, settingApi } from '@/api/index'
export default {
  name: 'DashBoard',
  data() {
    return {
      noticeList: [],
      activeNames: ['1'],
      userInfo: {},
      backendUrl: {}
    };
  },
  methods: {
    toMessage() {
      this.$router.push('/CustomerMassmessage')
    },
    handleChange(val) {
      console.log(val);
    },
    navigateToAccountIn() {
      // 使用 $router.push 实现页面跳转
      this.$router.push('/accountIn');
    },
    Applywithdrawl() {
      this.$router.push('/applywithdrawl');
    },

    /* 配置 在线客服 */
    getSetting() {
      settingApi().then(res => {
        this.backendUrl = res.data.service_url
        console.log(this.backendUrl, "请求地址")
      })
    },

    /* 获取用户信息 */
    getUserInfo() {
      // 从localStorage中获取token
      const storedToken = localStorage.getItem('token');
      if (storedToken) {
        const params = {
          token: storedToken
        };
        UserInfoApi(params).then(res => {
          this.userInfo = res.data
          console.log(this.userInfo)
        });
      }
    },
    /* 消息公告列表 */
    getNotice() {
      noticeListApi().then(res => {
        this.noticeList = res.data.data
      })
    },
    /* 消息公告详情 */
    getNoticeDetail() {
      noticedetailApi().then(res => {
      })
    },

  },
  created() {
    this.getUserInfo()
    this.getNotice()
    this.getSetting()
  },
  components: { LineChart, DayChart }
}
</script>

<style lang="scss" scoped>
:deep(.el-progress-bar__outer) {
  background-color: rgba(255, 255, 255, 0.4);
  /* lightgray, but transparent */

}

/* 进度条颜色 我需要的是渐变色 */
:deep(.el-progress-bar__inner) {
  background-color: white;
  //background: linear-gradient(90deg, #FEC015 0%, #FE8B25 100%);
}

.press:hover{
  cursor: pointer;
}
.custom-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  //gap: 10px;

  color: white;
}

.topbox {
  width: 100%;
  height: 21px;
  display: flex;
  font-size: 13px;

  // justify-content: space-around;
  .small {
    width: 152px;
    // background-color: pink;
  }

  .small2 {
    width: 152px;
    // background-color: pink;
  }
}

.chart-wrapper {
  width: 100%;
  /* 确保内部图表容器充满el-col */
}

.dashboard-editor-container {
  padding: 32px;
  background-color: rgb(240, 242, 245);
  position: relative;

  /*   .github-corner {
    position: absolute;
    top: 0px;
    border: 0;
    right: 0;
  } */

  .chart-wrapper {
    background: #fff;
    padding: 16px 16px 0;
    margin-bottom: 32px;
  }
}

:deep(.el-table thead) {
  color: white;
}

:deep(.el-table th.el-table__cell) {
  background-color: rgb(70, 69, 69);
}
</style>
